<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>我的客户主界面</title>
    <script type="text/javascript">
			//修改客户
			function update(id){
				var url='${pageContext.request.contextPath }/customer.action?method=queryCustomerById&cusid='+id;
      			window.location.href=url;
			}
			//分页查询
			function skipPage(currentPage){
        		var url='${pageContext.request.contextPath }/customer.action?method=queryCustomer&currPage='+currentPage;
        		window.location.href=url;
      		}
      		//添加客户
      		function addCustomer(){
      			var url='${pageContext.request.contextPath }/customer.action?method=now';
      			window.location.href=url;
      		}
      		//删除客户
      		function del(id){
      			if(confirm("您确定要删除吗？")){
      				var url='${pageContext.request.contextPath }/customer.action?method=delCustomerById&cusid='+id;
      				window.location.href=url;
      			}
      		}
      		var oldColor;
			function choice(trObj) {
				oldColor = trObj.bgColor;
				trObj.bgColor = "yellow";
			}
			function leave(trObj) {
				trObj.bgColor = oldColor;
			}
    </script>
    <style type="text/css">
    	a{
    		cursor:pointer;
    	}
    body {
				background-image:
				url(${pageContext.request.contextPath}/images/forum7.jpg);
			}
    </style>
  </head>
  
  <body>
  <form action="${pageContext.request.contextPath}/customer.action?method=queryCustomer" method="post">
  		客户id:<input type="text" name="cid" id="cid" value="${requestScope.ucid}">
  		客户姓名:<input type="text" name="name" id="name" value="${requestScope.ucname}">
  		公司名称:<input type="text" name="cmpname" id="cmpname" value="${requestScope.uccmpname}">
  		<input type="submit" value="查找">
		<center><button type="button" onclick="addCustomer();">添加客户</button></center>
    	<div style="height:320px;">
    	<table align="center" border="1px" cellspacing="0px" cellpadding="0px">
    		<tr>
    			<td>客户id</td>
    			<td>客户姓名</td>
    			<td>电话号码</td>
    			<td>邮箱</td>
    			<td>公司名称</td>
    			<td>操作</td>
    		</tr>
        	<c:forEach items="${requestScope.cuspage.cusdata}" var="view" varStatus="c">
        	<tr bgcolor="${c.index%2==0?'white':'skyblue'}" onmouseover=choice(this); onmouseout=leave(this);>
            	<td>${view.cusId }</td>
                <td>${view.cusName }</td>
                <td>${view.cusPhone }</td>
                <td>${view.cusEmail }</td>
                <td>${view.companyName }</td>
                <td><a onclick="update('${view.cusId}');">修改</a>&nbsp;<a onclick="del('${view.cusId }');">删除</a></td>
            </tr>
        </c:forEach>       
    </table>
    </div>
    <table align="center">
			<tr>
				<td>
					<a onclick="skipPage('1')";>首页</a>
				</td>
				<td>
					<a
						onclick="skipPage('${requestScope.cuspage.currentPage==1?1:requestScope.cuspage.currentPage-1 }');">上一页</a>
				</td>
				<td>
					<a
						onclick="skipPage('${requestScope.cuspage.currentPage==requestScope.cuspage.totalPage?(requestScope.cuspage.currentPage):(requestScope.cuspage.currentPage+1) }');">下一页</a>
				</td>
				<td>
					<a onclick="skipPage('${requestScope.cuspage.totalPage}');">末页</a>
				</td>
				<td>
					当前页码：${requestScope.cuspage.currentPage}/${requestScope.cuspage.totalPage}
				</td>
			</tr>
		</table>
		</form>
  </body>
</html>
